package com.bins.jpa.common.response;

public class ResultBody {

    private int code;
    private String msg;
    private Object data;

    public ResultBody() {
    }

    public ResultBody(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultBody(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResultBody isOK() {
        ResultBody rb = new ResultBody();
        rb.code = 0;
        rb.msg = "成功";
        return rb;
    }

    public static ResultBody isOK(Object data) {
        ResultBody rb = new ResultBody();
        rb.code = 0;
        rb.msg = "成功";
        rb.data = data;
        return rb;
    }

    public static ResultBody isFail() {
        ResultBody rb = new ResultBody();
        rb.code = 1;
        rb.msg = "失败";
        return rb;
    }

    public static ResultBody isFail(String msg) {
        ResultBody rb = new ResultBody();
        rb.code = 1;
        rb.msg = msg;
        return rb;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
